<?php
//简单管理页面范例，在你的管理页面引用coresection/checkA.php就OK，当然，不要忘了添加注销登录的链接
include_once '../coresection/checkA.php';
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--網站語言-->
    <meta http-equiv="Content-Language" content="zh-cn">
    <!--網站編碼-->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title><?php include '../coresection/title.php'; ?></title>
    <link rel="Shortcut Icon" href="../coresection/logoicon.ico">


</head>

<body style="display: none">
<? $system_part = $_REQUEST ['now_extender']; ?>

<?
include_once("../../config.php");
$host = $_SERVER['HTTP_HOST']; //取得进入所输入的域名
$theme_folder = host_theme($host);

include_once '../../front/' . $theme_folder . '/connection.php';
?>

<?php include_once("function.php"); ?>
<?php include "../../front/" . $theme_folder . "/config.php"; ?>




<?php
$new_term_nid = $_REQUEST['term_nid'];

//传递过来的页面信息。返回的时候，会根据这些信息返回原来的页面

$nowpageid = $_REQUEST['nowpageid'];
$sortby = $_REQUEST['sortby'];

?>







<?
//设置需要搜索的表格的前缀后缀
$table_Suffix = $sys_term_table;
$table = $table_Prefix . $table_Suffix;
//设置需要搜索的表格的前缀后缀
?>



<?php
//上传ICON===========================================================

//print_r($_FILES["upfile"]);
if (is_uploaded_file($_FILES['icon']['tmp_name'])) {
    $upfile = $_FILES["icon"];
    //获取数组里面的值


//获取当前日期
    $datename = date("Y-m-d H:i:s");
    $datename = str_replace("-", "", $datename);
    $datename = str_replace(" ", "", $datename);
    $datename = str_replace(":", "", $datename);


    $datename = $datename . "0";


//     $name=$upfile["name"];//上传文件的文件名,$name可以赋值其他值来到改变文件名,获取日期+时分秒来到改名最佳。而存放地点则按照月份来区分

    $name = $upfile["name"]; //上传的文件名改为时间命名
    $cutto = strrpos($name, "."); //返回第二个字符串在第一个字符串第一次出现的位置，第一个字符位置算0
    $name = substr_replace($name, $datename, 0, $cutto);


    $type = $upfile["type"]; //上传文件的类型


    $size = $upfile["size"]; //上传文件的大小
    $tmp_name = $upfile["tmp_name"]; //上传文件的临时存放路径
    /*
    这是一种非常简单文件上传方式。基于安全方面的考虑，您应当增加有关什么用户有权上传文件的限制。
    上传限制
    在这个脚本中，我们增加了对文件上传的限制。用户只能上传 .gif 或 .jpeg 文件
    */
    switch ($type) {
        case 'image/pjpeg':
            $okType = true;
            break;
        case 'image/jpeg':
            $okType = true;
            break;
        case 'image/gif':
            $okType = true;
            break;
        case 'image/png':
            $okType = true;
            break;
    }


    if ($okType) {
        /**
         * 0:文件上传成功<br/>
         * 1：超过了文件大小，在php.ini文件中设置<br/>
         * 2：超过了文件的大小MAX_FILE_SIZE选项指定的值<br/>
         * 3：文件只有部分被上传<br/>
         * 4：没有文件被上传<br/>
         * 5：上传文件大小为0
         */
        $error = $upfile["error"]; //上传后系统返回的值
        echo "================<br/>";
        echo "上传文件名称是：" . $name . "<br/>";
        echo "上传文件类型是：" . $type . "<br/>";
        echo "上传文件大小是：" . $size . "<br/>";
        echo "上传后系统返回的值是：" . $error . "<br/>";
        echo "上传文件的临时存放路径是：" . $tmp_name . "<br/>";

        echo "开始移动上传文件<br/>";
        //把上传的临时文件移动到up目录下面
        move_uploaded_file($tmp_name, '../../uploadfiles/' . $theme_folder . '/' . $name);
        $icon = $name;
        echo "================<br/>";
        echo "上传信息：<br/>";
        if ($error == 0) {
            echo "文件上传成功啦！";
            echo "<br>图片预览:<br>";
            echo "<img src=" . $destination . ">";
            //echo " alt="图片预览:r文件名:".$destination."r上传时间:">";
        } elseif ($error == 1) {
            echo "超过了文件大小，在php.ini文件中设置";
        } elseif ($error == 2) {
            echo "超过了文件的大小MAX_FILE_SIZE选项指定的值";
        } elseif ($error == 3) {
            echo "文件只有部分被上传";
        } elseif ($error == 4) {
            echo "没有文件被上传";
        } else {
            echo "上传文件大小为0";
        }
    } else {
        echo "请上传jpg,gif,png等格式的图片！";
    }


    $sql = "update $table SET icon = '$icon' where nid=$new_term_nid";
    $query = mysql_query($sql) or die ('保存term表失败查询失败');
    mysql_close($con);


}
?>





<?php
//上传Banner===========================================================

//print_r($_FILES["upfile"]);
if (is_uploaded_file($_FILES['banner']['tmp_name'])) {
    $upfile = $_FILES["banner"];
    //获取数组里面的值


//获取当前日期
    $datename = date("Y-m-d H:i:s");
    $datename = str_replace("-", "", $datename);
    $datename = str_replace(" ", "", $datename);
    $datename = str_replace(":", "", $datename);


    $datename = $datename . "1";


//     $name=$upfile["name"];//上传文件的文件名,$name可以赋值其他值来到改变文件名,获取日期+时分秒来到改名最佳。而存放地点则按照月份来区分

    $name = $upfile["name"]; //上传的文件名改为时间命名
    $cutto = strrpos($name, "."); //返回第二个字符串在第一个字符串第一次出现的位置，第一个字符位置算0
    $name = substr_replace($name, $datename, 0, $cutto);


    $type = $upfile["type"]; //上传文件的类型


    $size = $upfile["size"]; //上传文件的大小
    $tmp_name = $upfile["tmp_name"]; //上传文件的临时存放路径
    /*
    这是一种非常简单文件上传方式。基于安全方面的考虑，您应当增加有关什么用户有权上传文件的限制。
    上传限制
    在这个脚本中，我们增加了对文件上传的限制。用户只能上传 .gif 或 .jpeg 文件
    */
    switch ($type) {
        case 'image/pjpeg':
            $okType = true;
            break;
        case 'image/jpeg':
            $okType = true;
            break;
        case 'image/gif':
            $okType = true;
            break;
        case 'image/png':
            $okType = true;
            break;
    }


    if ($okType) {
        /**
         * 0:文件上传成功<br/>
         * 1：超过了文件大小，在php.ini文件中设置<br/>
         * 2：超过了文件的大小MAX_FILE_SIZE选项指定的值<br/>
         * 3：文件只有部分被上传<br/>
         * 4：没有文件被上传<br/>
         * 5：上传文件大小为0
         */
        $error = $upfile["error"]; //上传后系统返回的值
        echo "================<br/>";
        echo "上传文件名称是：" . $name . "<br/>";
        echo "上传文件类型是：" . $type . "<br/>";
        echo "上传文件大小是：" . $size . "<br/>";
        echo "上传后系统返回的值是：" . $error . "<br/>";
        echo "上传文件的临时存放路径是：" . $tmp_name . "<br/>";

        echo "开始移动上传文件<br/>";
        //把上传的临时文件移动到up目录下面
        move_uploaded_file($tmp_name, '../../uploadfiles/' . $theme_folder . '/' . $name);
        $banner = $name;
        echo "================<br/>";
        echo "上传信息：<br/>";
        if ($error == 0) {
            echo "文件上传成功啦！";
            echo "<br>图片预览:<br>";
            echo "<img src=" . $destination . ">";
            //echo " alt="图片预览:r文件名:".$destination."r上传时间:">";
        } elseif ($error == 1) {
            echo "超过了文件大小，在php.ini文件中设置";
        } elseif ($error == 2) {
            echo "超过了文件的大小MAX_FILE_SIZE选项指定的值";
        } elseif ($error == 3) {
            echo "文件只有部分被上传";
        } elseif ($error == 4) {
            echo "没有文件被上传";
        } else {
            echo "上传文件大小为0";
        }
    } else {
        echo "请上传jpg,gif,png等格式的图片！";
    }


    $sql = "update $table SET term_banner = '$banner' where nid=$new_term_nid";

    $query = mysql_query($sql) or die ('保存term表失败查询失败');
    mysql_close($con);


}
?>





<?php
//上传备用图片===========================================================

//print_r($_FILES["upfile"]);
if (is_uploaded_file($_FILES['extend_img']['tmp_name'])) {
    $upfile = $_FILES["extend_img"];
    //获取数组里面的值


//获取当前日期
    $datename = date("Y-m-d H:i:s");
    $datename = str_replace("-", "", $datename);
    $datename = str_replace(" ", "", $datename);
    $datename = str_replace(":", "", $datename);


    $datename = $datename . "2";


//     $name=$upfile["name"];//上传文件的文件名,$name可以赋值其他值来到改变文件名,获取日期+时分秒来到改名最佳。而存放地点则按照月份来区分

    $name = $upfile["name"]; //上传的文件名改为时间命名
    $cutto = strrpos($name, "."); //返回第二个字符串在第一个字符串第一次出现的位置，第一个字符位置算0
    $name = substr_replace($name, $datename, 0, $cutto);


    $type = $upfile["type"]; //上传文件的类型


    $size = $upfile["size"]; //上传文件的大小
    $tmp_name = $upfile["tmp_name"]; //上传文件的临时存放路径
    /*
    这是一种非常简单文件上传方式。基于安全方面的考虑，您应当增加有关什么用户有权上传文件的限制。
    上传限制
    在这个脚本中，我们增加了对文件上传的限制。用户只能上传 .gif 或 .jpeg 文件
    */
    switch ($type) {
        case 'image/pjpeg':
            $okType = true;
            break;
        case 'image/jpeg':
            $okType = true;
            break;
        case 'image/gif':
            $okType = true;
            break;
        case 'image/png':
            $okType = true;
            break;
    }


    if ($okType) {
        /**
         * 0:文件上传成功<br/>
         * 1：超过了文件大小，在php.ini文件中设置<br/>
         * 2：超过了文件的大小MAX_FILE_SIZE选项指定的值<br/>
         * 3：文件只有部分被上传<br/>
         * 4：没有文件被上传<br/>
         * 5：上传文件大小为0
         */
        $error = $upfile["error"]; //上传后系统返回的值
        echo "================<br/>";
        echo "上传文件名称是：" . $name . "<br/>";
        echo "上传文件类型是：" . $type . "<br/>";
        echo "上传文件大小是：" . $size . "<br/>";
        echo "上传后系统返回的值是：" . $error . "<br/>";
        echo "上传文件的临时存放路径是：" . $tmp_name . "<br/>";

        echo "开始移动上传文件<br/>";
        //把上传的临时文件移动到up目录下面
        move_uploaded_file($tmp_name, '../../uploadfiles/' . $theme_folder . '/' . $name);
        $extend_img = $name;
        echo "================<br/>";
        echo "上传信息：<br/>";
        if ($error == 0) {
            echo "文件上传成功啦！";
            echo "<br>图片预览:<br>";
            echo "<img src=" . $destination . ">";
            //echo " alt="图片预览:r文件名:".$destination."r上传时间:">";
        } elseif ($error == 1) {
            echo "超过了文件大小，在php.ini文件中设置";
        } elseif ($error == 2) {
            echo "超过了文件的大小MAX_FILE_SIZE选项指定的值";
        } elseif ($error == 3) {
            echo "文件只有部分被上传";
        } elseif ($error == 4) {
            echo "没有文件被上传";
        } else {
            echo "上传文件大小为0";
        }
    } else {
        echo "请上传jpg,gif,png等格式的图片！";
    }


    $sql = "update $table SET extend_img = '$extend_img' where nid=$new_term_nid";
    $query = mysql_query($sql) or die ('保存term表失败查询失败');
    mysql_close($con);


}
?>




<?php

$new_term_mid = $_REQUEST['term_mid'];
$new_term_name = $_REQUEST['term_name'];
$new_term_title = $_REQUEST['term_title'];
$new_term_keyword = $_REQUEST['term_keyword'];
$new_term_description = $_REQUEST['term_description'];
$new_term_url = $_REQUEST['term_url'];
$new_term_introduce = $_REQUEST['term_introduce'];
$new_term_name = $_REQUEST['term_name'];
$new_term_detail = $_REQUEST['term_detail'];

$new_term_listorder = $_REQUEST['term_listorder'];
$new_term_hotsale = $_REQUEST['term_hotsale'];

$new_term_recommend = $_REQUEST['term_recommend'];

$new_term_publish = $_REQUEST['term_publish'];

$new_term_clickrate = $_REQUEST['term_clickrate'];
$new_term_inputtime = $_REQUEST['term_inputtime'];
$new_term_modifytime = $_REQUEST['term_modifytime'];

$new_term_id                 = $_REQUEST['term_term_id'];


$new_term_link               = $_REQUEST['term_link'];
$new_term_mark            = $_REQUEST['term_mark'];
$new_term_markorder   = $_REQUEST['term_markorder'];
$new_term_vip               = $_REQUEST['term_vip'];


$new_term_term_id             = $_REQUEST['term_term_id'];
$new_term_interm               = $_REQUEST['term_interm'];


if($new_term_interm=='term1')
{
	echo $sql_str=" term1 = '$new_term_term_id' ";
}
else
{
	echo $sql_str=" term2 = '$new_term_term_id' ,";
}

?>






<?php
/*因为不能对分类进行升降级所以省略掉更新关于分类层
//此段函数，根据获取过来的id，查询出所属分类的term1~term5，interm
if($new_term_id == 'root')
{
	$trans_term_term0=0;
    $trans_term_interm='root';

}

else
  { 
  
       
 $result = mysql_query("select * from $table where nid = $new_term_id");
//根据ID,获取相应的所属分类资料
while($row = mysql_fetch_array($result))
  {
  
  $trans_term_nid=$new_term_id;
  $trans_term_term0=$row['term0'];
  $trans_term_term1=$row['term1'];
  $trans_term_term2=$row['term2'];
  $trans_term_term3=$row['term3'];
  $trans_term_term4=$row['term4'];
  $trans_term_term5=$row['term5'];
  $trans_term_interm=$row['interm'];
}
//下面这个判断，选择root没问题，其他的if else要修改一下
 if ($trans_term_interm == "root")
 {$trans_term_term1=$new_term_id;$trans_term_interm="term1";}
 
 else if ($trans_term_interm == "term1")
 {$trans_term_term2=$trans_term_nid;$trans_term_interm="term2";}
 
 else if ($trans_term_interm == "term2")
 {$trans_term_term3=$trans_term_nid;$trans_term_interm="term3";}
 
 else if ($trans_term_interm == "term3")
 
 {$trans_term_term4=$trans_term_nid;$trans_term_interm="term4";}
 
 else if ($trans_term_interm == "term4")
 {$trans_term_term5=$trans_term_nid;$trans_term_interm="term5";}
 
 

}
 
mysql_close($con);
*/


 
?>







<?

echo $sql = "update $table SET 
mid              = '$new_term_mid',
title            = '$new_term_title',
name             = '$new_term_name',
keyword          = '$new_term_keyword',
description      = '$new_term_description',
url              = '$new_term_url',

introduce        = '$new_term_introduce',
detail           = '$new_term_detail',
hotsale          = '$new_term_hotsale',
recommend        = '$new_term_recommend',
listorder        = '$new_term_listorder' ,
clickrate        = '$new_term_clickrate' ,
inputtime        = '$new_term_inputtime',
modifytime       = '$new_term_modifytime',
publish          = '$new_term_publish',".$sql_str."

link             = '$new_term_link',
mark             = '$new_term_mark',
markorder        = '$new_term_markorder',
vip_term         = '$new_term_vip'
where nid        = $new_term_nid";

//因为不能对分类进行升降级所以省略掉更新关于分类层级的语句,term0='$trans_term_term0',term1='$trans_term_term1',term2='$trans_term_term2',term3='$trans_term_term3',term4='$trans_term_term4',term5='$trans_term_term5',interm='$trans_term_interm'

$query = mysql_query($sql) or die ('此次数据库操作失败');
mysql_close($con);

?>






<script type="text/javascript">
    alert("输入信息已保存，点击确认返回继续操作.");
    document.location.href = "term-list.php?nowpageid=<? echo $nowpageid ?>&sortby=<? echo $sortby?>&now_extender=<? echo $system_part ?>";
</script>

</body>